package cn.iocoder.yudao.module.system.controller.admin.mini.userInfo.user.dal.mysql.user;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.mini.userInfo.user.controller.admin.user.vo.UserExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.userInfo.user.controller.admin.user.vo.UserPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.userInfo.user.dal.dataobject.user.UserDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 小程序-用户 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface QdUserMapper extends BaseMapperX<UserDO> {

    default PageResult<UserDO> selectPage(UserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserDO>()
                .betweenIfPresent(UserDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UserDO::getOpenId, reqVO.getOpenId())
                .likeIfPresent(UserDO::getId, reqVO.getId())
                .likeIfPresent(UserDO::getNickName, reqVO.getNickName())
                .likeIfPresent(UserDO::getPhone, reqVO.getPhone())
                .likeIfPresent(UserDO::getMail, reqVO.getMail())
                .eqIfPresent(UserDO::getIsVip, reqVO.getIsVip())
                .betweenIfPresent(UserDO::getVipTime, reqVO.getVipTime())
                .eqIfPresent(UserDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(UserDO::getSearchs, reqVO.getSearchs())
                .eqIfPresent(UserDO::getVipCode, reqVO.getVipCode())
                .eqIfPresent(UserDO::getDeductionPrice, reqVO.getDeductionPrice())
                .orderByDesc(UserDO::getId));
    }

    default List<UserDO> selectList(UserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<UserDO>()
                .betweenIfPresent(UserDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UserDO::getOpenId, reqVO.getOpenId())
                .likeIfPresent(UserDO::getNickName, reqVO.getNickName())
                .eqIfPresent(UserDO::getPhone, reqVO.getPhone())
                .eqIfPresent(UserDO::getIsVip, reqVO.getIsVip())
                .betweenIfPresent(UserDO::getVipTime, reqVO.getVipTime())
                .eqIfPresent(UserDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(UserDO::getSearchs, reqVO.getSearchs())
                .eqIfPresent(UserDO::getVipCode, reqVO.getVipCode())
                .eqIfPresent(UserDO::getDeductionPrice, reqVO.getDeductionPrice())
                .orderByDesc(UserDO::getId));
    }

}
